home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / makedev-.5 / makedev- / makedev-1.5 / parser.c < prev    next >
C/C++ Source or Header  |  1995-06-04  |  53KB  |  1,667 lines

  1. /*
  2.  * parser.c: Parser for MAKEDEV, a program to create entries in /dev.
  3.  *
  4.  * Based on the MAKEDEV shell script, version 2.0, distributed with
  5.  * util-linux 1.10 and written by Nick Holloway. 
  6.  *
  7.  * A number of bugs were fixed, and some additional features added.
  8.  * Written 10-Dec-94 by David A. Holland, dholland@husc.harvard.edu
  9.  * Rik Faith (faith@cs.unc.edu) contributed ideas and patches.
  10.  *
  11.  * Copyright 1994, 1995. All rights reserved. 
  12.  * See the file LEGAL.NOTICE for conditions of redistribution.
  13.  *
  14.  * Bugs:
  15.  *    None known right now.
  16.  *
  17.  * History:
  18.  *
  19.  * Version 2: 25-Mar-95    Fixed makefile. 
  20.  *    Look for config files in ".." under testing conditions.
  21.  *    Big source split: makedev.syn -> parser.syn and devices.c.
  22.  *    Consequently, this file's version numbers aren't the same as the
  23.  *    whole program's any more.
  24.  * Version 1.4b: 25-Mar-95 Merged Rik's changes. Additional bug fixes:
  25.  *    Don't leave off the last entry in a range.
  26.  *    Parse hex digits correctly [sigh...].
  27.  *    Now we actually *use* the ishex flag.
  28.  * Version 1.4a: 26-Feb-95 Forced devinfo and makedev.cfg to be in /etc.
  29.  *                         [from faith@cs.unc.edu]
  30.  * Version 1.4: 15-Jan-95  Wrote man pages. Now reads DEVINFO.local.
  31.  * Version 1.3: 31-Dec-94  Bug fixes. Added batches. Added omits.
  32.  * Version 1.2: 11-Dec-94  Add configuration file parsing.
  33.  * Version 1.1: 11-Dec-94  Distinguish block and character devices in the
  34.  *    table of major device numbers. Changed the name and format of the
  35.  *    update cache file to include the type. It appears that the old script
  36.  *    was broken in this regard.
  37.  * Version 1.0: 10-Dec-94  Initial version.
  38.  */
  39.  
  40.  
  41. #include <stdio.h>
  42. #include <stdlib.h>
  43. #include <string.h>
  44. #include <stdarg.h>
  45. #include <unistd.h>
  46. #include <fcntl.h>
  47. #include <pwd.h>
  48. #include <grp.h>
  49. #include <sys/stat.h>
  50.  
  51. #include "devices.h"
  52.  
  53.  
  54.  
  55. /*
  56.  
  57.  AnaGram Parsing Engine
  58.  Copyright (c) 1993, Parsifal Software.
  59.  This module may be copied and/or distributed at the discretion of the
  60.  AnaGram licensee.
  61.  
  62. */
  63.  
  64.  
  65.  
  66. #ifndef PARSER_H
  67. #include "parser.h"
  68. #endif
  69.  
  70. #include <ctype.h>
  71. #include <stdlib.h>
  72. #include <stdio.h>
  73. #include <string.h>
  74.  
  75. #define RULE_CONTEXT (&((PCB).cs[(PCB).ssx]))
  76. #define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx])
  77. #define CONTEXT ((PCB).cs[(PCB).ssx])
  78.  
  79.  
  80.  
  81. parse_pcb_type parse_pcb;
  82. #define PCB parse_pcb
  83.  
  84. #line 56 "/usr/home/dholland/Programs/Utils/makedev/current/parser.syn"
  85. /************************* parsing support *************************/
  86.  
  87. /*
  88.  * Don't use the built-in error printing.
  89.  */
  90. #define SYNTAX_ERROR
  91. #define PARSER_STACK_OVERFLOW
  92. #define REDUCTION_TOKEN_ERROR
  93.  
  94. void doparse(FILE *f, int filetype, const char *filename) {
  95.   char *x;
  96.   int i=0, len;
  97.   if (filetype<1 || filetype>4) crash("tried to parse a bad file type");
  98.   if (filetype!=1) { /* /proc/devices won't stat intelligently */
  99.     struct stat buf;
  100.     if (fstat(fileno(f), &buf)) crash("fstat failed?!?");
  101.     len = buf.st_size;
  102.   }
  103.   else len=1023;
  104.   x = malloc(len+1);
  105.   if (!x) crash("Out of memory");
  106.  
  107.   len = fread(x, 1, len, f);  /* it shouldn't return a short count... */
  108.   if (len<0) crash("fread failed?!?");
  109.   x[len]=0;
  110.  
  111.   init_parse();
  112.   PCB.input_code = filetype+'0';
  113.   parse();
  114.   PCB.column--; /* correct for the filetype token */
  115.   while (!PCB.exit_flag) {
  116.     PCB.input_code = x[i++];
  117.     parse();
  118.   }
  119.   if (PCB.exit_flag == AG_SYNTAX_ERROR_CODE) {
  120.     warn("syntax error: %s, line %d, column %d in file %s",
  121.          PCB.error_message, PCB.line, PCB.column, filename);
  122.     crash("Sorry, can't continue.");
  123.   }
  124.   else if (PCB.exit_flag != AG_SUCCESS_CODE) {
  125.     crash("parser stack overflow!");
  126.   }
  127. }
  128.  
  129. #define STRINGSIZE 8192
  130. static char string_space[STRINGSIZE];
  131. static int stringptr=0;
  132.  
  133. static const char *string_start(int c) {
  134.   if (stringptr>=STRINGSIZE) crash("out of string space");
  135.   return string_space[stringptr]=c, string_space+stringptr++;
  136. }
  137.  
  138. static void string_push(int c) {
  139.   if (stringptr>=STRINGSIZE) crash("out of string space");
  140.   string_space[stringptr++] = c;
  141. }
  142.  
  143. static void string_finish(void) {
  144.   string_push(0);
  145. }
  146.  
  147.  
  148. #line 148 "parser.c"
  149. #line 198 "/usr/home/dholland/Programs/Utils/makedev/current/parser.syn"
  150.   static const char *cur_group=NULL, *cur_class=NULL;
  151.   static int cur_type;
  152.   static int cur_maj=0, cur_min=0, cur_bot=0, cur_top=0, ishex=0;
  153.  
  154.   static void dhsproc(const char *g, const char *p, int t, int m) {
  155.     cur_group = g;
  156.     cur_type = t;
  157.     cur_maj = get_major(p, (t=='c'), m);
  158.     cur_min = 0;
  159.     cur_bot = cur_top = ishex = 0;
  160.     if (p) addalias(p,g);
  161.   }
  162.  
  163.   static void newdev(const char *n) {
  164.     if (cur_maj<0) return;
  165.     init(n, cur_group, cur_class, cur_maj, cur_min, cur_type);
  166.   }
  167.   static void devrange(const char *n, const char *n1) {
  168.     char temp[32];
  169.     if (cur_maj<0) return;
  170.     sprintf(temp, "%s%%%c%s", n, ishex ? 'x' : 'd', n1 ? n1 : "");
  171.     initlots(temp, cur_bot, cur_top, cur_group, cur_class,
  172.          cur_maj, cur_min, cur_type);
  173.   }
  174.   static void doinitlink(const char *src, const char *tg) {
  175.     if (cur_maj>=0) initlink(src, cur_group, tg);
  176.   }
  177.  
  178. #line 178 "parser.c"
  179. #ifndef CONVERT_CASE
  180. #define CONVERT_CASE(c) (c)
  181. #endif
  182. #ifndef TAB_SPACING
  183. #define TAB_SPACING 8
  184. #endif
  185.  
  186. #define ag_rp_1(n, s) (set_major(s,YES,n))
  187.  
  188. #define ag_rp_2(n, s) (set_major(s,NO,n))
  189.  
  190. #define ag_rp_3(n, maj, t) (updatefromcache(n,maj,t))
  191.  
  192. #define ag_rp_4() ('b')
  193.  
  194. #define ag_rp_5() ('c')
  195.  
  196. #define ag_rp_8(n, i) (add2batch(addbatch(n), i))
  197.  
  198. #define ag_rp_9(b, i) (add2batch(b,i))
  199.  
  200. #define ag_rp_10(n) (n)
  201.  
  202. #define ag_rp_11(n) (ignore_procname(n))
  203.  
  204. #define ag_rp_12(t, g, p) (dhsproc(g,p,t,-1))
  205.  
  206. #define ag_rp_13(t, g, p, m) (dhsproc(g,p,t,m))
  207.  
  208. #define ag_rp_14(t, g, m) (dhsproc(g,NULL,t,m))
  209.  
  210. #define ag_rp_15(classname) (classname)
  211.  
  212. #define ag_rp_16(c, min) ((cur_class=c, cur_min=min))
  213.  
  214. #define ag_rp_17(a, b) (cur_bot=a, cur_top=b, ishex=0)
  215.  
  216. #define ag_rp_18(a, b) (cur_bot=a, cur_top=b, ishex=1)
  217.  
  218. #define ag_rp_19(n) (newdev(n))
  219.  
  220. #define ag_rp_20(n, n1) (devrange(n,n1))
  221.  
  222. #define ag_rp_21(n) (devrange(n,NULL))
  223.  
  224. #define ag_rp_22(n, a, b, p, m) (initdisk(n, a, b, p, cur_maj, m))
  225.  
  226. #define ag_rp_23(n, tg) (doinitlink(n, tg))
  227.  
  228. #define ag_rp_24(n) (n)
  229.  
  230. #define ag_rp_25(n) (n)
  231.  
  232. #define ag_rp_26(n) (n)
  233.  
  234. #define ag_rp_27(n, o, g, m) (addclass(n,o,g,m))
  235.  
  236. #define ag_rp_28(n) (make(n, M_OMIT))
  237.  
  238. #define ag_rp_29(n) (make(n, M_OMIT))
  239.  
  240. #define ag_rp_30(n) (n)
  241.  
  242. #define ag_rp_31(s) (string_finish(), s)
  243.  
  244. #define ag_rp_32(s) (s)
  245.  
  246. #define ag_rp_33(c) (string_start(c))
  247.  
  248. #define ag_rp_34(s, c) (string_push(c), s)
  249.  
  250. #define ag_rp_35(s) (string_finish(), s)
  251.  
  252. #define ag_rp_36(c) (string_start(c))
  253.  
  254. #define ag_rp_37(s, c) (string_push(c), s)
  255.  
  256. #define ag_rp_38(c) (c)
  257.  
  258. #define ag_rp_39() ('\\')
  259.  
  260. #define ag_rp_40() ('"')
  261.  
  262. #define ag_rp_41(d) (d-'0')
  263.  
  264. #define ag_rp_42(n, d) (n*10 + d-'0')
  265.  
  266. #define ag_rp_43(d) (d)
  267.  
  268. #define ag_rp_44(n, d) (16*n+d)
  269.  
  270. #define ag_rp_45(d) (d)
  271.  
  272. #define ag_rp_46(n, d) (16*n+d)
  273.  
  274. #define ag_rp_47(d) (d-'0')
  275.  
  276. #define ag_rp_48(d) (10 + d-'a')
  277.  
  278. #define ag_rp_49(d) (10 + d-'A')
  279.  
  280. #define ag_rp_50(d) (d-'0')
  281.  
  282. #define ag_rp_51(n, d) (n*8+d-'0')
  283.  
  284. #define ag_rp_52(x, t) (x+t)
  285.  
  286. #define ag_rp_53(x, t) (x-t)
  287.  
  288. #define ag_rp_54(t, f) (t*f)
  289.  
  290. #define ag_rp_55(f) (-f)
  291.  
  292. #define ag_rp_56(x) (x)
  293.  
  294.  
  295. #define READ_COUNTS 
  296. #define WRITE_COUNTS 
  297. static parse_vs_type ag_null_value;
  298. #define V(i,t) (*(t *) (&(PCB).vs[(PCB).ssx + i]))
  299. #define VS(i) (PCB).vs[(PCB).ssx + i]
  300.  
  301. #ifndef GET_CONTEXT
  302. #define GET_CONTEXT CONTEXT = (PCB).input_context
  303. #endif
  304.  
  305. typedef enum {
  306.   ag_action_1,
  307.   ag_action_2,
  308.   ag_action_3,
  309.   ag_action_4,
  310.   ag_action_5,
  311.   ag_action_6,
  312.   ag_action_7,
  313.   ag_action_8,
  314.   ag_action_9,
  315.   ag_action_10,
  316.   ag_action_11,
  317.   ag_action_12
  318. } ag_parser_action;
  319.  
  320. static int ag_ap;
  321.  
  322.  
  323.  
  324. static const unsigned char ag_rpx[] = {
  325.     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  2,
  326.     0,  0,  0,  3,  4,  5,  4,  5,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  327.     0,  0,  0,  6,  0,  0,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
  328.    19, 20, 21, 22, 23, 24,  0,  0,  0,  0,  0, 25, 26,  0,  0,  0, 27, 28,
  329.     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
  330.    29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,  0,  0, 41, 42, 43, 44,
  331.    45, 46, 47, 48, 49,  0, 50, 51,  0, 52,  0,  0, 53, 54
  332. };
  333.  
  334. static unsigned char ag_key_itt[] = {
  335.  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  336.  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  337.  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
  338.  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
  339.  0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  340.  1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  341.  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  342.  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  343.  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  344.  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  345.  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  346.  0
  347. };
  348.  
  349. static unsigned short ag_key_pt[] = {
  350.   1,122,  1,123,  1,126,  1,127,  1,139,  1,140,0
  351. };
  352.  
  353. static unsigned char ag_key_ch[] = {
  354.     0, 47,255, 42,255, 42, 47,255, 88,120,255, 97,108,255,104,108,255, 45,
  355.    47, 48, 66, 67, 98, 99,105,111,255, 42, 47,255, 47, 99,111,255, 42, 47,
  356.   255, 97,108,255, 47, 98, 99,105,255, 42, 47,255, 47,255, 42, 47,255, 47,
  357.    66, 67,255, 47, 99,111,255, 97,108,255, 47, 98, 99,105,255, 47,255, 47,
  358.    66, 67,255, 42, 47,255, 97,108,255,104,108,255, 47, 66, 67, 98, 99,105,
  359.   111,255, 97,108,255,104,108,255, 47, 66, 67, 98, 99,105,111,255, 99,111,
  360.   255, 97,108,255, 98, 99,105,255, 66, 67,255, 42, 47,255, 45, 47,255, 88,
  361.   120,255, 47, 48,255, 42, 47,255, 47, 98, 99,255, 98, 99,255, 42, 47,255,
  362.    97,108,255,104,108,255, 47, 98, 99,105,111,255, 45,255, 88,120,255, 48,
  363.   255
  364. };
  365.  
  366. static unsigned char ag_key_act[] = {
  367.   0,3,4,3,4,0,0,4,0,0,4,7,7,4,7,7,4,3,2,2,3,3,2,2,7,7,4,0,0,4,2,7,7,4,0,
  368.   0,4,7,7,4,2,2,7,7,4,0,0,4,2,4,0,0,4,2,3,3,4,3,7,7,4,7,7,4,3,2,7,7,4,3,
  369.   4,3,3,3,4,0,0,4,7,7,4,7,7,4,2,3,3,2,2,7,7,4,7,7,4,7,7,4,3,3,3,2,2,7,7,
  370.   4,7,7,4,7,7,4,2,7,7,4,3,3,4,0,0,4,3,2,4,0,0,4,3,2,4,0,0,4,2,7,7,4,7,7,
  371.   4,0,0,4,7,7,4,7,7,4,2,2,2,7,7,4,3,4,0,0,4,2,4
  372. };
  373.  
  374. static unsigned char ag_key_parm[] = {
  375.     0, 80,  0, 84,  0, 80, 86,  0,146,145,  0,  6,  0,  0,  2,  8,  0,138,
  376.     0,  0,119,118,  0,  0,  4, 10,  0, 80, 86,  0,  0,  8, 10,  0, 80, 86,
  377.     0,  6,  0,  0,  0,  0,  2,  4,  0, 80, 86,  0,  0,  0, 80, 86,  0,  0,
  378.   119,118,  0, 86,  8, 10,  0,  6,  0,  0, 86,  0,  2,  4,  0, 86,  0, 86,
  379.   119,118,  0, 80, 86,  0,  6,  0,  0,  2,  8,  0,  0,119,118,  0,  0,  4,
  380.    10,  0,  6,  0,  0,  2,  8,  0, 86,119,118,  0,  0,  4, 10,  0,  8, 10,
  381.     0,  6,  0,  0,  0,  2,  4,  0,119,118,  0, 80, 86,  0,138,  0,  0,146,
  382.   145,  0, 80,  0,  0, 80, 86,  0,  0,  0,  2,  0,  0,  2,  0, 80, 86,  0,
  383.     6,  0,  0,  2,  8,  0,  0,  0,  0,  4, 10,  0,138,  0,146,145,  0,  0,
  384.     0
  385. };
  386.  
  387. static unsigned short ag_key_jmp[] = {
  388.     0,  0,  0,  2,  0,  0,  0,  0,  0,  0,  0, 38, 42,  0, 46, 49,  0,  4,
  389.     5,  8,  6, 20, 11, 14, 53, 59,  0,  0,  0,  0, 27, 63, 68,  0,  0,  0,
  390.     0, 72, 76,  0, 34, 37, 80, 84,  0,  0,  0,  0, 45,  0,  0,  0,  0, 50,
  391.    90,104,  0,122,124,129,  0,135,139,  0,133, 61,143,147,  0,153,  0,155,
  392.   157,171,  0,  0,  0,  0,221,225,  0,229,232,  0, 75,189,203, 78, 81,236,
  393.   242,  0,280,284,  0,288,291,  0,246,248,262, 92, 95,295,301,  0,305,310,
  394.     0,314,318,  0,109,322,326,  0,332,346,  0,  0,  0,  0,364,119,  0,  0,
  395.     0,  0,366,125,  0,  0,  0,  0,131,368,373,  0,377,382,  0,  0,  0,  0,
  396.   386,390,  0,394,397,  0,141,144,147,401,407,  0,411,  0,  0,  0,  0,158,
  397.     0
  398. };
  399.  
  400. static unsigned short ag_key_index[] = {
  401.     1,  3, 17,  0,  3,  3, 30, 40, 48, 53, 57, 64, 69, 71,  0,  0, 84, 98,
  402.   106,112,  0,116,  0,  1,  1,  0,  0,106, 48, 48, 48, 48,  1,  1,  0,  0,
  403.     0, 69,112,  0,122, 48,  0,  0, 48, 48, 69, 69,116, 48, 69, 69,  0,128,
  404.     0,  0,  0, 69,  0, 69,  0,  0,134,138,  0,  0,  0,128,  0,  0, 69, 48,
  405.    69,  0,150, 64,  0,156,  0, 69,  0,116,  0,116, 69,  0,  0,  0,  1,  0,
  406.     0, 69, 69,  0,  1,  0,128,161,  0,  0,  0,  0,  0, 69, 69,  0, 57,  0,
  407.     0,  0, 69,  0, 64, 69,  1,  0,  1,  1,  0,  0,  0,  0,  0,161, 64, 48,
  408.    69, 69, 48,  0,128,  0, 48, 48,  0,  0,161,161, 69, 69, 69, 69,  0,  0,
  409.     0,  0,  0,128,161,161,128,161,  1,  0, 69, 69,  0,  1,  0, 69,  0
  410. };
  411.  
  412. static unsigned char ag_key_ends[] = {
  413. 42,0, 47,0, 62,0, 108,111,99,107,32,100,101,118,105,99,101,115,58,0, 
  414. 104,97,114,97,99,116,101,114,32,100,101,118,105,99,101,115,58,0, 
  415. 116,99,104,0, 111,99,107,0, 97,114,0, 97,115,115,0, 
  416. 103,110,111,114,101,0, 109,105,116,0, 108,97,115,115,0, 
  417. 109,105,116,0, 116,99,104,0, 111,99,107,0, 104,97,114,0, 
  418. 103,110,111,114,101,0, 108,111,99,107,32,100,101,118,105,99,101,115,58,0, 
  419. 104,97,114,97,99,116,101,114,32,100,101,118,105,99,101,115,58,0, 
  420. 47,0, 108,97,115,115,0, 109,105,116,0, 47,0, 116,99,104,0, 
  421. 111,99,107,0, 104,97,114,0, 103,110,111,114,101,0, 47,0, 47,0, 
  422. 108,111,99,107,32,100,101,118,105,99,101,115,58,0, 
  423. 104,97,114,97,99,116,101,114,32,100,101,118,105,99,101,115,58,0, 
  424. 108,111,99,107,32,100,101,118,105,99,101,115,58,0, 
  425. 104,97,114,97,99,116,101,114,32,100,101,118,105,99,101,115,58,0, 
  426. 116,99,104,0, 111,99,107,0, 97,114,0, 97,115,115,0, 
  427. 103,110,111,114,101,0, 109,105,116,0, 47,0, 
  428. 108,111,99,107,32,100,101,118,105,99,101,115,58,0, 
  429. 104,97,114,97,99,116,101,114,32,100,101,118,105,99,101,115,58,0, 
  430. 116,99,104,0, 111,99,107,0, 97,114,0, 97,115,115,0, 
  431. 103,110,111,114,101,0, 109,105,116,0, 108,97,115,115,0, 
  432. 109,105,116,0, 116,99,104,0, 111,99,107,0, 104,97,114,0, 
  433. 103,110,111,114,101,0, 108,111,99,107,32,100,101,118,105,99,101,115,58,0, 
  434. 104,97,114,97,99,116,101,114,32,100,101,118,105,99,101,115,58,0, 
  435. 62,0, 42,0, 108,111,99,107,0, 104,97,114,0, 108,111,99,107,0, 
  436. 104,97,114,0, 116,99,104,0, 111,99,107,0, 97,114,0, 97,115,115,0, 
  437. 103,110,111,114,101,0, 109,105,116,0, 62,0, 
  438. };
  439. #define AG_TCV(x) (((int)(x) >= -1 && (int)(x) <= 255) ? ag_tcv[(x) + 1] : 0)
  440.  
  441. static const unsigned char ag_tcv[] = {
  442.    18, 18,154,154,154,154,154,154,154,154,152, 93,154,154,152,154,154,154,
  443.   154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,153,155, 95,
  444.    87,155,155,155,155,131,129,151,150,128,134,155,136,156,114,115,116,117,
  445.   156,156,156,157,157,132,155,155,130,155,155,155,148,148,148,148,148,148,
  446.   158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,
  447.   158,158,135, 99,133,155,158,155,159,120,121,159,159,159,158,158,158,158,
  448.   158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,125,155,
  449.   124,155,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,
  450.   154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,
  451.   154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,
  452.   154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,
  453.   154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,
  454.   154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,
  455.   154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,
  456.   154,154,154,154,154
  457. };
  458.  
  459. #ifndef SYNTAX_ERROR
  460. #define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n", \
  461.   (PCB).error_message, (PCB).line, (PCB).column)
  462. #endif
  463.  
  464. #ifndef FIRST_LINE
  465. #define FIRST_LINE 1
  466. #endif
  467.  
  468. #ifndef FIRST_COLUMN
  469. #define FIRST_COLUMN 1
  470. #endif
  471.  
  472.  
  473. #ifndef PARSER_STACK_OVERFLOW
  474. #define PARSER_STACK_OVERFLOW {fprintf(stderr, \
  475.    "\nParser stack overflow, line %d, column %d\n",\
  476.    (PCB).line, (PCB).column);}
  477. #endif
  478.  
  479. #ifndef REDUCTION_TOKEN_ERROR
  480. #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \
  481.     "\nReduction token error, line %d, column %d\n", \
  482.     (PCB).line, (PCB).column);}
  483. #endif
  484.  
  485.  
  486. typedef enum
  487.   {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key,
  488.    ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words;
  489.  
  490.  
  491. static void ag_track(void) {
  492.   int ag_k = 0;
  493.   while (ag_k < (PCB).rx) {
  494.     int ag_ch = (PCB).lab[ag_k++];
  495.     switch (ag_ch) {
  496.     case '\n':
  497.       (PCB).column = 1, (PCB).line++;
  498.     case '\r':
  499.     case '\f':
  500.       break;
  501.     case '\t':
  502.       (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING);
  503.       break;
  504.     default:
  505.       (PCB).column++;
  506.     }
  507.   }
  508.   ag_k = 0;
  509.   while ((PCB).rx < (PCB).fx) (PCB).lab[ag_k++] = (PCB).lab[(PCB).rx++];
  510.   (PCB).fx = ag_k;
  511.   (PCB).rx = 0;
  512. }
  513.  
  514.  
  515. static void ag_prot(void) {
  516.   int ag_k = 38 - ++(PCB).btsx;
  517.   if (ag_k <= (PCB).ssx) {
  518.     (PCB).exit_flag = AG_STACK_ERROR_CODE;
  519.     PARSER_STACK_OVERFLOW;
  520.     return;
  521.   }
  522.   (PCB).bts[(PCB).btsx] = (PCB).sn;
  523.   (PCB).bts[ag_k] = (PCB).ssx;
  524.   (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx];
  525.   (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx];
  526. }
  527.  
  528. static void ag_undo(void) {
  529.   if ((PCB).drt == -1) return;
  530.   while ((PCB).btsx) {
  531.     int ag_k = 38 - (PCB).btsx;
  532.     (PCB).sn = (PCB).bts[(PCB).btsx--];
  533.     (PCB).ssx = (PCB).bts[ag_k];
  534.     (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k];
  535.     (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k];
  536.   }
  537.   (PCB).token_number = (parse_token_type) (PCB).drt;
  538.   (PCB).ssx = (PCB).dssx;
  539.   (PCB).sn = (PCB).dsn;
  540.   (PCB).drt = -1;
  541. }
  542.  
  543.  
  544. static const unsigned char ag_tstt[] = {
  545. 153,152,80,0,2,112,113,
  546. 159,158,157,156,155,154,153,152,151,150,148,136,135,134,133,132,131,130,129,
  547.   128,125,124,121,120,117,116,115,114,99,95,93,87,0,82,83,
  548. 153,152,80,0,2,
  549. 117,116,115,114,0,5,6,8,10,12,
  550. 159,158,157,156,155,154,153,152,151,150,148,136,135,134,133,132,131,130,129,
  551.   128,125,124,121,120,117,116,115,114,99,95,93,87,0,
  552. 84,0,
  553. 153,152,80,0,2,112,113,
  554. 153,152,80,0,2,112,113,
  555. 153,152,80,0,2,112,113,
  556. 153,152,80,0,2,112,113,
  557. 140,139,93,87,86,0,3,13,14,15,85,88,92,141,
  558. 127,126,123,122,121,120,93,87,86,0,3,11,14,15,85,88,92,141,
  559. 159,158,148,134,121,120,95,93,87,86,0,3,9,14,15,85,88,92,141,
  560. 119,118,93,87,86,0,3,7,14,15,85,88,92,141,
  561. 159,158,157,156,155,154,153,152,151,150,148,136,135,134,133,132,131,130,129,
  562.   128,125,124,121,120,117,116,115,114,99,95,87,18,0,90,91,
  563. 93,0,
  564. 153,152,80,0,2,112,113,
  565. 159,158,157,156,148,140,139,134,128,127,126,124,123,122,121,120,119,118,117,
  566.   116,115,114,95,93,87,86,18,0,3,88,92,141,
  567. 140,139,0,69,70,71,72,73,75,
  568. 127,126,123,122,121,120,0,29,30,31,32,33,34,35,36,42,45,
  569. 159,158,148,134,121,120,95,0,1,4,26,27,28,142,143,
  570. 119,118,0,16,17,19,22,
  571. 159,158,157,156,155,154,153,152,151,150,148,136,135,134,133,132,131,130,129,
  572.   128,125,124,121,120,117,116,115,114,99,95,87,18,0,
  573. 153,152,80,0,2,112,113,
  574. 153,152,80,0,2,112,113,
  575. 159,158,148,134,125,121,120,95,0,1,4,26,37,142,143,
  576. 159,158,148,134,121,120,95,0,1,4,26,142,143,
  577. 140,139,18,0,69,71,72,73,75,
  578. 153,152,80,0,2,112,113,
  579. 153,152,80,0,2,112,113,
  580. 153,152,80,0,2,112,113,
  581. 153,152,80,0,2,112,113,
  582. 153,152,80,0,2,112,113,
  583. 153,152,80,0,2,112,113,
  584. 131,0,50,
  585. 159,158,148,134,121,120,95,0,1,4,26,46,142,143,
  586. 125,0,37,
  587. 159,158,148,134,125,121,120,95,93,87,86,0,3,14,15,37,85,88,92,141,
  588. 127,126,123,122,121,120,18,0,29,30,31,32,33,34,36,42,45,
  589. 159,158,157,156,155,153,151,150,148,136,135,134,133,132,131,130,129,128,125,
  590.   124,121,120,117,116,115,114,99,87,0,96,97,
  591. 153,152,80,0,2,112,113,
  592. 159,158,157,156,153,152,148,134,121,120,117,116,115,114,80,0,2,112,113,
  593. 157,156,117,116,115,114,0,25,100,
  594. 159,158,148,134,121,120,95,18,0,1,4,26,27,142,143,
  595. 153,152,80,0,2,112,113,
  596. 153,152,80,0,2,112,113,
  597. 87,86,0,3,14,85,88,92,141,
  598. 87,86,0,3,14,85,88,92,141,
  599. 119,118,18,0,16,19,22,
  600. 153,152,80,0,2,112,113,
  601. 159,158,148,134,121,120,95,93,87,86,0,3,14,15,85,88,92,141,
  602. 87,86,0,3,14,85,88,92,141,
  603. 132,0,57,
  604. 153,152,80,0,2,112,113,
  605. 159,158,148,134,121,120,95,0,1,4,26,51,142,143,
  606. 125,0,37,
  607. 128,124,0,41,48,49,
  608. 159,158,148,134,121,120,95,93,87,86,0,3,14,15,85,88,92,141,
  609. 159,158,148,134,121,120,95,0,1,4,26,38,65,142,143,
  610. 159,158,148,134,124,121,120,95,93,87,86,0,3,14,15,85,88,92,141,
  611. 99,95,0,
  612. 159,158,157,156,155,153,151,150,148,136,135,134,133,132,131,130,129,128,125,
  613.   124,121,120,117,116,115,114,99,95,87,0,97,
  614. 153,152,80,0,2,112,113,
  615. 157,156,123,122,121,120,117,116,115,114,0,29,30,31,32,33,100,
  616. 157,156,117,116,115,114,0,23,24,25,100,
  617. 157,156,117,116,115,114,0,20,21,25,100,
  618. 159,158,148,134,121,120,95,0,1,4,26,76,77,142,143,
  619. 153,152,80,0,2,112,113,
  620. 159,158,148,134,121,120,95,0,1,4,26,142,143,
  621. 130,128,0,48,52,
  622. 159,158,148,134,121,120,95,93,87,86,0,3,14,15,85,88,92,141,
  623. 153,152,80,0,2,112,113,
  624. 159,158,148,134,124,121,120,95,93,87,86,0,3,14,15,85,88,92,141,
  625. 159,158,148,134,121,120,95,0,1,4,26,47,142,143,
  626. 153,152,80,0,2,112,113,
  627. 127,126,123,122,121,120,93,87,86,18,0,3,14,15,85,88,92,141,
  628. 159,158,148,134,121,120,95,0,1,4,26,43,44,142,143,
  629. 138,135,131,0,50,55,56,59,60,68,
  630. 159,158,148,134,121,120,95,0,1,4,26,38,39,40,65,142,143,
  631. 87,86,0,3,14,85,88,92,141,
  632. 159,158,157,156,148,134,121,120,117,116,115,114,95,0,1,4,26,100,142,143,
  633. 157,156,117,116,115,114,0,23,25,100,
  634. 159,158,157,156,148,134,121,120,117,116,115,114,95,0,1,4,26,100,142,143,
  635. 157,156,117,116,115,114,0,20,25,100,
  636. 159,158,148,134,128,124,121,120,95,93,87,86,0,3,14,15,85,88,92,141,
  637. 159,158,148,134,124,121,120,95,0,1,4,26,41,76,142,143,
  638. 159,158,148,134,121,120,95,0,1,4,26,142,143,
  639. 157,156,117,116,115,114,0,25,100,
  640. 153,152,80,0,2,112,113,
  641. 159,158,148,134,121,120,95,0,1,4,26,53,142,143,
  642. 159,158,148,134,121,120,95,0,1,4,26,47,142,143,
  643. 159,158,148,134,128,124,121,120,95,93,87,86,0,3,14,15,85,88,92,141,
  644. 159,158,148,134,128,124,121,120,95,93,87,86,0,3,14,15,85,88,92,141,
  645. 159,158,148,134,124,121,120,95,0,1,4,26,41,43,142,143,
  646. 153,152,80,0,2,112,113,
  647. 159,158,148,134,121,120,95,0,1,4,26,142,143,
  648. 153,152,80,0,2,112,113,
  649. 159,158,157,156,148,146,145,134,121,120,117,116,115,114,0,25,63,66,100,101,
  650.   102,103,
  651. 159,158,148,134,131,121,120,95,0,1,4,26,50,55,56,65,142,143,
  652. 159,158,148,134,121,120,95,0,1,4,26,142,143,
  653. 132,0,57,
  654. 159,158,148,134,121,120,95,0,1,4,26,38,65,142,143,
  655. 124,0,41,
  656. 87,86,0,3,14,85,88,92,141,
  657. 87,86,0,3,14,85,88,92,141,
  658. 128,0,48,49,
  659. 140,139,93,87,86,18,0,3,14,15,85,88,92,141,
  660. 156,117,116,115,114,0,74,78,107,
  661. 157,156,129,117,116,115,114,0,54,100,
  662. 129,128,0,48,54,
  663. 159,158,148,134,128,124,121,120,95,93,87,86,0,3,14,15,85,88,92,141,
  664. 128,0,48,49,
  665. 127,126,123,122,121,120,93,87,86,18,0,3,14,15,85,88,92,141,
  666. 87,86,0,3,14,85,88,92,141,
  667. 153,152,80,0,2,112,113,
  668. 134,0,61,
  669. 153,152,80,0,2,112,113,
  670. 153,152,80,0,2,112,113,
  671. 159,157,156,148,121,120,117,116,115,114,0,100,104,105,106,
  672. 159,157,156,148,134,121,120,117,116,115,114,0,61,100,104,105,106,
  673. 157,156,134,117,116,115,114,0,61,100,
  674. 131,0,50,55,56,
  675. 129,0,54,
  676. 157,156,146,145,134,131,117,116,115,114,0,25,50,58,61,63,100,101,102,103,
  677.   108,110,
  678. 127,126,123,122,121,120,93,87,86,18,0,3,14,15,85,88,92,141,
  679. 153,152,80,0,2,112,113,
  680. 156,117,116,115,114,0,107,
  681. 87,86,0,3,14,85,88,92,141,
  682. 153,152,80,0,2,112,113,
  683. 157,156,117,116,115,114,0,25,100,
  684. 153,152,80,0,2,112,113,
  685. 159,158,148,134,121,120,0,66,
  686. 153,152,80,0,2,112,113,
  687. 153,152,80,0,2,112,113,
  688. 159,157,156,148,121,120,117,116,115,114,0,64,100,104,105,106,
  689. 157,156,117,116,115,114,0,25,100,
  690. 157,156,146,145,134,131,117,116,115,114,0,25,50,58,61,63,100,101,102,103,
  691.   108,110,
  692. 157,156,146,145,134,131,117,116,115,114,0,25,50,61,63,100,101,102,103,110,
  693. 159,157,156,148,121,120,117,116,115,114,0,100,104,105,106,
  694. 157,156,117,116,115,114,0,100,
  695. 151,0,111,
  696. 150,134,87,86,0,3,14,61,85,88,92,109,141,
  697. 157,156,129,117,116,115,114,0,54,100,
  698. 133,0,62,
  699. 159,157,156,148,133,121,120,117,116,115,114,0,62,100,104,105,106,
  700. 157,156,133,117,116,115,114,0,62,100,
  701. 150,134,129,0,54,61,109,
  702. 153,152,80,0,2,112,113,
  703. 157,156,146,145,134,131,117,116,115,114,0,25,50,61,63,100,101,102,103,110,
  704. 157,156,146,145,134,131,117,116,115,114,0,25,50,61,63,100,101,102,103,108,
  705.   110,
  706. 153,152,80,0,2,112,113,
  707. 157,156,146,145,134,131,117,116,115,114,0,25,50,61,63,100,101,102,103,108,
  708.   110,
  709. 153,152,80,0,2,112,113,
  710. 157,156,117,116,115,114,0,25,100,
  711. 151,0,111,
  712. 151,0,111,
  713. 157,156,136,117,116,115,114,0,67,100,
  714. 153,152,80,0,2,112,113,
  715. 157,156,117,116,115,114,0,25,100,
  716. 157,156,117,116,115,114,87,86,0,3,14,85,88,92,100,141,
  717.   0
  718. };
  719.  
  720.  
  721. static unsigned char ag_astt[1882] = {
  722.   1,1,1,8,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  723.   1,1,8,1,1,9,9,1,5,3,1,1,1,1,7,0,1,1,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
  724.   9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,5,3,7,1,1,1,5,1,1,3,1,1,1,5,1,1,3,1,1,1,5,1,
  725.   1,3,1,1,1,5,1,1,3,8,8,8,1,1,7,1,3,1,1,1,1,1,1,8,8,8,8,8,8,8,1,1,7,1,3,1,1,
  726.   1,1,1,1,8,8,8,8,8,8,8,8,1,1,7,1,3,1,1,1,1,1,1,8,8,8,1,1,7,1,3,1,1,1,1,1,1,
  727.   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,1,3,3,7,
  728.   1,1,1,5,1,1,3,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,8,1,1,5,7,3,1,
  729.   1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,7,1,2,2,2,2,1,1,1,1,1,2,2,2,2,2,2,1,7,2,
  730.   2,1,1,1,1,1,1,1,7,1,1,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
  731.   9,9,9,9,9,9,9,9,5,1,1,1,5,1,1,3,1,1,1,5,1,1,3,2,2,2,2,1,2,2,1,7,2,2,1,1,1,
  732.   1,2,2,2,2,2,2,1,7,2,2,1,1,1,1,1,3,7,3,3,3,1,1,1,1,1,5,1,1,3,1,1,1,5,1,1,3,
  733.   1,1,1,5,1,1,3,1,1,1,5,1,1,3,1,1,1,5,1,1,3,1,1,1,5,1,1,3,1,7,1,2,2,2,2,2,2,
  734.   1,7,2,2,1,1,1,1,1,7,1,8,8,8,8,1,8,8,8,8,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
  735.   3,7,1,2,2,2,2,3,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
  736.   1,2,7,1,2,1,1,1,5,1,1,3,10,10,10,10,1,1,10,10,10,10,10,10,10,10,1,5,1,1,3,
  737.   1,1,1,1,1,1,7,1,2,2,2,2,2,2,2,1,3,7,2,2,1,3,1,1,1,1,1,5,1,1,3,1,1,1,5,1,1,
  738.   3,1,1,8,1,1,1,1,1,1,1,1,8,1,1,1,1,1,1,1,1,3,7,3,1,1,1,1,1,5,1,1,3,8,8,8,8,
  739.   8,8,8,8,1,1,7,1,1,1,1,1,1,1,1,1,8,1,2,1,1,1,1,1,7,1,1,1,1,5,1,1,3,2,2,2,2,
  740.   2,2,1,7,2,2,2,1,1,1,1,7,1,1,1,8,1,1,1,8,8,8,8,8,8,8,8,1,1,7,1,1,1,1,1,1,1,
  741.   2,2,2,2,2,2,1,7,2,2,2,3,1,1,1,8,8,8,8,8,8,8,8,8,1,1,7,1,1,1,1,1,1,1,2,2,7,
  742.   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,7,2,1,1,1,5,1,1,
  743.   3,1,1,1,1,1,1,1,1,1,1,7,1,2,2,2,2,2,1,1,1,1,1,1,7,1,1,1,2,1,1,1,1,1,1,7,1,
  744.   1,1,2,2,2,2,2,2,2,1,7,2,2,1,1,1,1,1,1,1,1,5,1,1,3,2,2,2,2,2,2,1,7,2,2,1,1,
  745.   1,1,1,7,1,1,8,8,8,8,8,8,8,8,1,1,7,1,1,1,1,1,1,1,1,1,1,5,1,1,3,5,5,5,5,5,5,
  746.   5,5,8,1,1,7,1,3,3,1,1,1,1,2,2,2,2,2,2,1,7,2,2,2,1,1,1,1,1,1,5,1,1,3,5,5,5,
  747.   5,5,5,8,1,1,5,7,1,3,3,1,1,1,1,2,2,2,2,2,2,1,7,2,2,1,1,1,1,1,1,1,1,7,1,1,2,
  748.   1,1,1,2,2,2,2,2,2,1,8,2,2,2,1,1,1,1,1,1,1,1,8,1,2,1,1,1,1,2,2,1,1,2,2,2,2,
  749.   1,1,1,1,1,7,2,2,1,2,1,1,1,1,1,1,1,1,5,3,1,2,2,2,1,1,2,2,2,2,1,1,1,1,1,7,2,
  750.   2,1,2,1,1,1,1,1,1,1,1,5,3,1,2,8,8,8,8,8,8,8,8,8,8,1,1,7,1,1,1,1,1,1,1,2,2,
  751.   2,2,1,2,2,1,7,2,2,1,1,3,1,1,2,2,2,2,2,2,1,7,2,2,1,1,1,1,1,1,1,1,1,7,1,2,1,
  752.   1,1,5,1,1,3,2,2,2,2,2,2,1,7,2,2,2,1,1,1,2,2,2,2,2,2,1,7,2,2,2,1,1,1,5,5,5,
  753.   5,5,5,5,5,5,8,1,1,7,1,2,2,1,1,1,1,8,8,8,8,8,8,8,8,8,8,1,1,7,1,1,1,1,1,1,1,
  754.   2,2,2,2,1,2,2,1,7,2,2,1,1,3,1,1,1,1,1,5,1,1,3,2,2,2,2,2,2,1,7,2,2,1,1,1,1,
  755.   1,1,5,1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,2,1,1,1,2,2,2,2,1,2,2,1,7,
  756.   2,2,2,1,1,2,1,1,1,2,2,2,2,2,2,1,7,2,2,1,1,1,1,7,1,2,2,2,2,2,2,1,5,2,2,2,3,
  757.   1,1,1,1,7,1,1,1,8,1,2,1,1,1,1,1,1,8,1,2,1,1,1,1,1,5,1,2,5,5,8,1,1,5,7,1,3,
  758.   3,1,1,1,1,1,1,1,1,1,7,1,1,2,1,1,1,1,1,1,1,7,2,2,1,1,7,1,2,5,5,5,5,5,5,5,5,
  759.   5,8,1,1,7,1,2,2,1,1,1,1,1,5,1,2,5,5,5,5,5,5,8,1,1,5,7,1,3,3,1,1,1,1,1,1,8,
  760.   1,2,1,1,1,1,1,1,1,5,1,1,3,1,7,1,1,1,1,5,1,1,3,1,1,1,5,1,1,3,1,1,1,1,1,1,1,
  761.   1,1,1,7,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,7,1,2,2,2,2,1,1,1,1,1,1,1,7,1,2,1,7,
  762.   1,1,2,1,7,2,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,1,2,1,1,1,1,1,5,5,5,5,5,5,8,1,1,
  763.   5,7,1,3,3,1,1,1,1,1,1,1,5,1,1,3,1,1,1,1,1,4,2,1,1,8,1,2,1,1,1,1,1,1,1,5,1,
  764.   1,3,1,1,1,1,1,1,7,1,2,1,1,1,5,1,1,3,1,1,1,1,1,1,7,1,1,1,1,5,1,1,3,1,1,1,5,
  765.   1,1,3,1,1,1,1,1,1,1,1,1,1,7,1,2,2,2,2,1,1,1,1,1,1,7,1,2,1,1,1,1,1,1,1,1,1,
  766.   1,7,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,2,1,1,1,2,1,1,1,1,
  767.   1,1,1,1,1,1,5,2,2,2,2,1,1,1,1,1,1,5,2,1,5,1,1,1,1,1,8,1,2,1,1,1,1,1,1,1,1,
  768.   1,1,1,1,1,7,2,2,1,7,1,1,1,1,1,1,1,1,1,1,1,1,7,2,2,2,2,2,1,1,1,1,1,1,1,7,2,
  769.   2,1,1,1,7,2,1,1,1,1,1,5,1,1,3,1,1,1,1,1,1,1,1,1,1,7,1,1,1,1,2,1,1,1,2,1,1,
  770.   1,1,1,1,1,1,1,1,7,1,1,1,1,2,1,1,1,1,1,1,1,1,5,1,1,3,1,1,1,1,1,1,1,1,1,1,7,
  771.   1,1,1,1,2,1,1,1,1,1,1,1,1,5,1,1,3,1,1,1,1,1,1,7,1,2,1,4,1,1,4,1,1,1,1,1,1,
  772.   1,1,7,1,2,1,1,1,5,1,1,3,1,1,1,1,1,1,7,1,2,1,1,1,1,1,1,1,1,8,1,2,1,1,1,2,1,11
  773. };
  774.  
  775.  
  776. static unsigned char ag_pstt[] = {
  777. 2,2,1,3,2,2,3,
  778. 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,4,5,
  779. 123,123,1,125,123,
  780. 6,7,8,9,3,0,13,12,11,10,
  781. 74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,74,
  782.   74,74,74,74,74,74,74,76,
  783. 77,5,
  784. 2,2,1,124,2,2,129,
  785. 2,2,1,124,2,2,128,
  786. 2,2,1,124,2,2,127,
  787. 2,2,1,124,2,2,126,
  788. 18,18,15,14,14,10,17,4,18,18,17,14,15,16,
  789. 19,19,19,19,19,19,15,14,14,11,17,3,19,19,17,14,15,16,
  790. 20,20,20,20,20,20,20,15,14,14,12,17,2,20,20,17,14,15,16,
  791. 21,21,15,14,14,13,17,1,21,21,17,14,15,16,
  792. 22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,
  793.   22,22,22,22,22,22,22,85,22,88,
  794. 89,15,
  795. 2,2,1,124,2,2,153,
  796. 80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,15,14,
  797.   14,80,17,79,14,15,16,
  798. 23,24,18,27,27,27,27,26,25,
  799. 32,33,28,29,30,31,19,34,22,23,24,25,38,38,37,36,35,
  800. 92,92,92,92,92,92,39,20,90,91,42,43,43,41,40,
  801. 44,45,21,48,48,47,46,
  802. 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,
  803.   84,84,84,84,84,84,84,86,
  804. 2,2,1,124,2,2,152,
  805. 2,2,1,124,2,2,151,
  806. 92,92,92,92,49,92,92,39,25,90,91,51,50,41,40,
  807. 92,92,92,92,92,92,39,26,90,91,52,41,40,
  808. 23,24,62,27,61,61,61,26,25,
  809. 2,2,1,124,2,2,135,
  810. 2,2,1,124,2,2,134,
  811. 2,2,1,124,2,2,133,
  812. 2,2,1,124,2,2,132,
  813. 2,2,1,124,2,2,139,
  814. 2,2,1,124,2,2,138,
  815. 53,34,54,
  816. 92,92,92,92,92,92,39,35,90,91,55,56,41,40,
  817. 49,36,57,
  818. 58,58,58,58,49,58,58,58,15,14,14,37,17,58,58,59,17,14,15,16,
  819. 32,33,28,29,30,31,28,38,34,22,23,24,25,27,37,36,35,
  820. 97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
  821.   97,60,97,39,61,95,
  822. 2,2,1,124,2,2,155,
  823. 93,93,93,93,2,2,93,93,93,93,93,93,93,93,1,124,2,2,154,
  824. 62,62,62,62,62,62,42,63,100,
  825. 92,92,92,92,92,92,39,20,43,90,91,42,19,41,40,
  826. 2,2,1,124,2,2,131,
  827. 2,2,1,124,2,2,130,
  828. 14,14,15,17,64,17,14,15,16,
  829. 14,14,15,17,65,17,14,15,16,
  830. 44,45,9,48,8,47,46,
  831. 2,2,1,124,2,2,137,
  832. 66,66,66,66,66,66,66,15,14,14,50,17,66,66,17,14,15,16,
  833. 14,14,15,17,66,17,14,15,16,
  834. 67,52,68,
  835. 2,2,1,124,2,2,143,
  836. 92,92,92,92,92,92,39,54,90,91,58,69,41,40,
  837. 49,55,70,
  838. 71,74,73,75,72,73,
  839. 76,76,76,76,76,76,76,15,14,14,57,17,76,76,17,14,15,16,
  840. 92,92,92,92,92,92,39,58,90,91,57,34,77,41,40,
  841. 78,78,78,78,78,78,78,78,15,14,14,59,17,78,78,17,14,15,16,
  842. 98,99,60,
  843. 97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,97,
  844.   97,60,94,97,61,96,
  845. 2,2,1,124,2,2,156,
  846. 62,62,28,29,30,31,62,62,62,62,63,79,22,23,24,25,101,
  847. 62,62,62,62,62,62,64,81,81,80,100,
  848. 62,62,62,62,62,62,65,83,83,82,100,
  849. 92,92,92,92,92,92,39,66,90,91,84,85,85,41,40,
  850. 2,2,1,124,2,2,144,
  851. 92,92,92,92,92,92,39,68,90,91,86,41,40,
  852. 88,71,69,87,89,
  853. 90,90,90,90,90,90,90,15,14,14,70,17,90,90,17,14,15,16,
  854. 2,2,1,124,2,2,140,
  855. 5,5,5,5,5,5,5,5,15,14,14,72,17,41,41,17,14,15,16,
  856. 92,92,92,92,92,92,39,73,90,91,43,91,41,40,
  857. 2,2,1,124,2,2,136,
  858. 5,5,5,5,5,5,15,14,14,5,75,17,38,38,17,14,15,16,
  859. 92,92,92,92,92,92,39,76,90,91,92,93,93,41,40,
  860. 94,96,53,77,99,100,52,98,97,95,
  861. 92,92,92,92,92,92,39,102,90,91,57,101,101,102,77,41,40,
  862. 14,14,15,17,21,17,14,15,16,
  863. 92,92,62,62,92,92,92,92,62,62,62,62,39,80,90,91,103,101,41,40,
  864. 62,62,62,62,62,62,15,14,80,100,
  865. 92,92,62,62,92,92,92,92,62,62,62,62,39,82,90,91,104,101,41,40,
  866. 62,62,62,62,62,62,12,11,82,100,
  867. 105,105,105,105,105,105,105,105,105,15,14,14,84,17,105,105,17,14,15,16,
  868. 92,92,92,92,74,92,92,39,85,90,91,84,106,68,41,40,
  869. 92,92,92,92,92,92,39,86,90,91,107,41,40,
  870. 62,62,62,62,62,62,87,108,100,
  871. 2,2,1,124,2,2,142,
  872. 92,92,92,92,92,92,39,89,90,91,59,109,41,40,
  873. 92,92,92,92,92,92,39,90,90,91,43,110,41,40,
  874. 5,5,5,5,5,5,5,5,5,15,14,14,91,17,42,42,17,14,15,16,
  875. 111,111,111,111,111,111,111,111,111,15,14,14,92,17,111,111,17,14,15,16,
  876. 92,92,92,92,74,92,92,39,93,90,91,92,112,36,41,40,
  877. 2,2,1,124,2,2,150,
  878. 92,92,92,92,92,92,39,95,90,91,113,41,40,
  879. 2,2,1,124,2,2,147,
  880. 114,114,62,62,114,116,117,114,114,114,62,62,62,62,97,120,119,115,100,118,
  881.   118,118,
  882. 92,92,92,92,53,92,92,39,98,90,91,57,99,100,54,121,41,40,
  883. 92,92,92,92,92,92,39,99,90,91,122,41,40,
  884. 67,100,123,
  885. 92,92,92,92,92,92,39,32,90,91,57,30,77,41,40,
  886. 74,102,124,
  887. 14,14,15,17,17,17,14,15,16,
  888. 14,14,15,17,16,17,14,15,16,
  889. 71,40,72,70,
  890. 5,5,15,14,14,5,106,17,69,69,17,14,15,16,
  891. 125,125,125,125,125,107,127,126,111,
  892. 62,62,128,62,62,62,62,108,47,101,
  893. 128,71,109,129,45,
  894. 5,5,5,5,5,5,5,5,5,15,14,14,110,17,39,39,17,14,15,16,
  895. 71,40,72,44,
  896. 5,5,5,5,5,5,15,14,14,5,112,17,37,37,17,14,15,16,
  897. 14,14,15,17,56,17,14,15,16,
  898. 2,2,1,124,2,2,149,
  899. 130,115,131,
  900. 2,2,1,124,2,2,158,
  901. 2,2,1,124,2,2,157,
  902. 132,62,62,133,132,132,62,62,62,62,118,108,104,109,110,
  903. 132,62,62,133,130,132,132,62,62,62,62,119,134,108,105,109,110,
  904. 62,62,130,62,62,62,62,120,135,101,
  905. 53,121,99,100,53,
  906. 128,122,48,
  907. 62,62,116,117,130,53,62,62,62,62,123,139,136,141,137,138,100,118,118,118,
  908.   140,140,
  909. 5,5,5,5,5,5,15,14,14,5,124,17,33,33,17,14,15,16,
  910. 2,2,1,124,2,2,161,
  911. 125,125,125,125,125,71,112,
  912. 14,14,15,17,65,17,14,15,16,
  913. 2,2,1,124,2,2,141,
  914. 62,62,62,62,62,62,129,142,100,
  915. 2,2,1,124,2,2,146,
  916. 114,114,114,114,114,114,131,143,
  917. 2,2,1,124,2,2,159,
  918. 2,2,1,124,2,2,160,
  919. 132,62,62,133,132,132,62,62,62,62,134,144,108,106,109,110,
  920. 62,62,62,62,62,62,135,145,100,
  921. 62,62,116,117,130,53,62,62,62,62,136,139,136,146,137,138,100,118,118,118,
  922.   140,140,
  923. 62,62,116,117,130,53,62,62,62,62,137,139,136,137,138,100,118,118,118,120,
  924. 132,62,62,133,132,132,62,62,62,62,119,108,105,109,110,
  925. 62,62,62,62,62,62,118,101,
  926. 147,113,148,
  927. 150,130,14,14,15,17,49,149,17,14,15,151,16,
  928. 62,62,128,62,62,62,62,142,46,101,
  929. 152,143,153,
  930. 132,62,62,133,152,132,132,62,62,62,62,144,51,108,107,109,110,
  931. 62,62,152,62,62,62,62,145,50,101,
  932. 150,130,128,146,121,149,151,
  933. 2,2,1,124,2,2,163,
  934. 62,62,116,117,130,53,62,62,62,62,148,139,136,137,138,100,118,118,118,117,
  935. 62,62,116,117,130,53,62,62,62,62,149,139,136,137,138,100,118,118,118,154,
  936.   154,
  937. 2,2,1,124,2,2,162,
  938. 62,62,116,117,130,53,62,62,62,62,151,139,136,137,138,100,118,118,118,155,
  939.   155,
  940. 2,2,1,124,2,2,145,
  941. 62,62,62,62,62,62,153,156,100,
  942. 147,115,148,
  943. 147,114,148,
  944. 62,62,157,62,62,62,62,156,158,101,
  945. 2,2,1,124,2,2,148,
  946. 62,62,62,62,62,62,158,159,100,
  947. 62,62,62,62,62,62,14,14,15,17,55,17,14,15,101,16,
  948.   0
  949. };
  950.  
  951.  
  952. static const unsigned short ag_sbt[] = {
  953.      0,   7,  42,  47,  57,  90,  92,  99, 106, 113, 120, 134, 152, 171,
  954.    185, 220, 222, 229, 261, 270, 287, 302, 309, 342, 349, 356, 371, 384,
  955.    393, 400, 407, 414, 421, 428, 435, 438, 452, 455, 475, 492, 523, 530,
  956.    549, 558, 573, 580, 587, 596, 605, 612, 619, 637, 646, 649, 656, 670,
  957.    673, 679, 697, 712, 731, 734, 765, 772, 789, 800, 811, 826, 833, 846,
  958.    851, 869, 876, 895, 909, 916, 934, 949, 959, 976, 985,1005,1015,1035,
  959.   1045,1065,1081,1094,1103,1110,1124,1138,1158,1178,1194,1201,1214,1221,
  960.   1243,1261,1274,1277,1292,1295,1304,1313,1317,1331,1340,1350,1355,1375,
  961.   1379,1397,1406,1413,1416,1423,1430,1445,1462,1472,1477,1480,1502,1520,
  962.   1527,1534,1543,1550,1559,1566,1574,1581,1588,1604,1613,1635,1655,1670,
  963.   1678,1681,1694,1704,1707,1724,1734,1741,1748,1768,1789,1796,1817,1824,
  964.   1833,1836,1839,1849,1856,1865,1881
  965. };
  966.  
  967.  
  968. static const unsigned short ag_sbe[] = {
  969.      3,  39,  45,  51,  89,  91,  95, 102, 109, 116, 125, 143, 162, 176,
  970.    217, 221, 225, 256, 263, 276, 294, 304, 341, 345, 352, 364, 378, 387,
  971.    396, 403, 410, 417, 424, 431, 436, 445, 453, 466, 482, 520, 526, 545,
  972.    555, 566, 576, 583, 589, 598, 608, 615, 629, 639, 647, 652, 663, 671,
  973.    675, 689, 704, 723, 733, 763, 768, 782, 795, 806, 818, 829, 840, 848,
  974.    861, 872, 887, 902, 912, 926, 941, 952, 966, 978, 998,1011,1028,1041,
  975.   1057,1073,1088,1100,1106,1117,1131,1150,1170,1186,1197,1208,1217,1235,
  976.   1251,1268,1275,1284,1293,1297,1306,1314,1323,1336,1347,1352,1367,1376,
  977.   1389,1399,1409,1414,1419,1426,1440,1456,1469,1473,1478,1490,1512,1523,
  978.   1532,1536,1546,1556,1562,1572,1577,1584,1598,1610,1623,1645,1665,1676,
  979.   1679,1685,1701,1705,1718,1731,1737,1744,1758,1778,1792,1806,1820,1830,
  980.   1834,1837,1846,1852,1862,1873,1881
  981. };
  982.  
  983.  
  984. static const unsigned char ag_fl[] = {
  985.   2,2,2,2,2,0,1,1,2,3,1,2,3,1,2,3,3,3,1,2,3,4,1,1,1,1,1,2,3,1,2,0,1,6,3,
  986.   1,2,6,4,5,0,2,4,1,3,6,8,6,3,4,5,5,2,4,3,10,4,1,1,1,1,2,3,1,1,7,3,1,2,6,
  987.   3,1,1,1,2,0,1,3,1,2,1,1,1,1,2,0,1,0,2,2,1,1,1,2,3,1,2,1,2,2,1,2,1,1,2,
  988.   2,1,2,1,1,1,1,2,1,3,3,1,3,1,1,2,3,1,2,0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
  989.   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  990. };
  991.  
  992. static const unsigned char ag_ptt[] = {
  993.     0,  5,  5,  5,  5, 15, 15, 17, 17,  7, 21, 21, 16, 24, 24, 16, 20, 23,
  994.    28, 28,  9, 27, 29, 29, 29, 29, 35, 35, 11, 39, 39, 40, 40, 34, 34, 44,
  995.    44, 34, 34, 46, 49, 49, 46, 47, 43, 36, 36, 36, 55, 56, 59, 59, 38, 38,
  996.    38, 38, 38, 65, 51, 53, 70, 70, 13, 69, 69, 71, 72, 77, 77, 72, 76, 74,
  997.     2, 82, 82, 83, 83,  2, 85, 85, 14, 88, 88, 90, 90, 91, 91, 92, 92,141,
  998.    26, 26,142,142,143, 96, 96, 97, 97, 97, 25, 25,103,103, 63, 63, 64, 64,
  999.   104,104,104, 78, 78, 58, 58, 58,108,108,110,110,110,110,112,112,113,113,
  1000.     6,  8, 10, 12, 19, 22, 30, 31, 32, 33, 41, 37, 42, 45, 48, 54, 52, 50,
  1001.    57, 62, 61, 60, 67, 66, 68, 73, 75,  3,  1,  4,100,101,102,105,106,107,
  1002.   109,111
  1003. };
  1004.  
  1005.  
  1006.  
  1007.  
  1008. static void ag_ra(void)
  1009. {
  1010.   switch(ag_rpx[ag_ap]) {
  1011.   case   1: ag_rp_1(V(0,int), V(1,const char *)); break;
  1012.   case   2: ag_rp_2(V(0,int), V(1,const char *)); break;
  1013.   case   3: ag_rp_3(V(0,const char *), V(1,int), V(2,char)); break;
  1014.   case   4: V(0,char) = ag_rp_4(); break;
  1015.   case   5: V(0,char) = ag_rp_5(); break;
  1016.   case   6: V(0,batch *) = ag_rp_8(V(0,const char *), V(3,const char *)); break;
  1017.   case   7: V(0,batch *) = ag_rp_9(V(0,batch *), V(2,const char *)); break;
  1018.   case   8: V(0,const char *) = ag_rp_10(V(0,const char *)); break;
  1019.   case   9: ag_rp_11(V(0,const char *)); break;
  1020.   case  10: ag_rp_12(V(0,char), V(2,const char *), V(4,const char *)); break;
  1021.   case  11: ag_rp_13(V(0,char), V(2,const char *), V(4,const char *), V(6,int)); break;
  1022.   case  12: ag_rp_14(V(0,char), V(2,const char *), V(4,int)); break;
  1023.   case  13: V(0,const char *) = ag_rp_15(V(1,const char *)); break;
  1024.   case  14: ag_rp_16(V(0,const char *), V(2,int)); break;
  1025.   case  15: ag_rp_17(V(1,int), V(3,int)); break;
  1026.   case  16: ag_rp_18(V(1,int), V(3,int)); break;
  1027.   case  17: ag_rp_19(V(0,const char *)); break;
  1028.   case  18: ag_rp_20(V(0,const char *), V(2,const char *)); break;
  1029.   case  19: ag_rp_21(V(0,const char *)); break;
  1030.   case  20: ag_rp_22(V(0,const char *), V(2,int), V(4,int), V(6,int), V(8,int)); break;
  1031.   case  21: ag_rp_23(V(0,const char *), V(2,const char *)); break;
  1032.   case  22: V(0,const char *) = ag_rp_24(V(0,const char *)); break;
  1033.   case  23: V(0,const char *) = ag_rp_25(V(0,const char *)); break;
  1034.   case  24: V(0,const char *) = ag_rp_26(V(0,const char *)); break;
  1035.   case  25: ag_rp_27(V(1,const char *), V(3,const char *), V(4,const char *), V(5,int)); break;
  1036.   case  26: ag_rp_28(V(1,const char *)); break;
  1037.   case  27: ag_rp_29(V(0,const char *)); break;
  1038.   case  28: V(0,int) = ag_rp_30(V(0,int)); break;
  1039.   case  29: V(0,const char *) = ag_rp_31(V(0,const char *)); break;
  1040.   case  30: V(0,const char *) = ag_rp_32(V(0,const char *)); break;
  1041.   case  31: V(0,const char *) = ag_rp_33(V(0,int)); break;
  1042.   case  32: V(0,const char *) = ag_rp_34(V(0,const char *), V(1,int)); break;
  1043.   case  33: V(0,const char *) = ag_rp_35(V(1,const char *)); break;
  1044.   case  34: V(0,const char *) = ag_rp_36(V(0,char)); break;
  1045.   case  35: V(0,const char *) = ag_rp_37(V(0,const char *), V(1,char)); break;
  1046.   case  36: V(0,char) = ag_rp_38(V(0,int)); break;
  1047.   case  37: V(0,char) = ag_rp_39(); break;
  1048.   case  38: V(0,char) = ag_rp_40(); break;
  1049.   case  39: V(0,int) = ag_rp_41(V(0,int)); break;
  1050.   case  40: V(0,int) = ag_rp_42(V(0,int), V(1,int)); break;
  1051.   case  41: V(0,int) = ag_rp_43(V(1,int)); break;
  1052.   case  42: V(0,int) = ag_rp_44(V(0,int), V(1,int)); break;
  1053.   case  43: V(0,int) = ag_rp_45(V(0,int)); break;
  1054.   case  44: V(0,int) = ag_rp_46(V(0,int), V(1,int)); break;
  1055.   case  45: V(0,int) = ag_rp_47(V(0,int)); break;
  1056.   case  46: V(0,int) = ag_rp_48(V(0,int)); break;
  1057.   case  47: V(0,int) = ag_rp_49(V(0,int)); break;
  1058.   case  48: V(0,int) = ag_rp_50(V(0,int)); break;
  1059.   case  49: V(0,int) = ag_rp_51(V(0,int), V(1,int)); break;
  1060.   case  50: V(0,int) = ag_rp_52(V(0,int), V(2,int)); break;
  1061.   case  51: V(0,int) = ag_rp_53(V(0,int), V(2,int)); break;
  1062.   case  52: V(0,int) = ag_rp_54(V(0,int), V(2,int)); break;
  1063.   case  53: V(0,int) = ag_rp_55(V(1,int)); break;
  1064.   case  54: V(0,int) = ag_rp_56(V(1,int)); break;
  1065.   }
  1066. }
  1067.  
  1068. #define TOKEN_NAMES parse_token_names
  1069. const char *parse_token_names[160] = {
  1070.   "file format",
  1071.   "identifier",
  1072.   "white space",
  1073.   "simple eol",
  1074.   "quoted string",
  1075.   "file format",
  1076.   "",
  1077.   "devices",
  1078.   "",
  1079.   "cache",
  1080.   "",
  1081.   "devinfo",
  1082.   "",
  1083.   "config",
  1084.   "eol",
  1085.   "",
  1086.   "device list",
  1087.   "",
  1088.   "eof",
  1089.   "",
  1090.   "character device",
  1091.   "",
  1092.   "",
  1093.   "block device",
  1094.   "",
  1095.   "number",
  1096.   "name",
  1097.   "cachedevice",
  1098.   "",
  1099.   "devicetype",
  1100.   "",
  1101.   "",
  1102.   "",
  1103.   "",
  1104.   "device block",
  1105.   "",
  1106.   "device header spec",
  1107.   "",
  1108.   "device decl",
  1109.   "",
  1110.   "",
  1111.   "",
  1112.   "",
  1113.   "ignoramus",
  1114.   "",
  1115.   "",
  1116.   "batch list",
  1117.   "batch item",
  1118.   "",
  1119.   "",
  1120.   "",
  1121.   "groupname",
  1122.   "",
  1123.   "procname",
  1124.   "",
  1125.   "class",
  1126.   "device tail",
  1127.   "",
  1128.   "expr",
  1129.   "device range",
  1130.   "",
  1131.   "",
  1132.   "",
  1133.   "hex number",
  1134.   "auto hex",
  1135.   "devname",
  1136.   "letter",
  1137.   "",
  1138.   "",
  1139.   "config decl",
  1140.   "",
  1141.   "class decl",
  1142.   "omit decl",
  1143.   "",
  1144.   "mode",
  1145.   "",
  1146.   "single omit",
  1147.   "",
  1148.   "octal number",
  1149.   "",
  1150.   "",
  1151.   "",
  1152.   "",
  1153.   "",
  1154.   "",
  1155.   "",
  1156.   "",
  1157.   "",
  1158.   "",
  1159.   "",
  1160.   "",
  1161.   "",
  1162.   "",
  1163.   "",
  1164.   "",
  1165.   "",
  1166.   "qstring",
  1167.   "qstring char",
  1168.   "qchar",
  1169.   "",
  1170.   "digit",
  1171.   "",
  1172.   "",
  1173.   "",
  1174.   "hex digit",
  1175.   "",
  1176.   "",
  1177.   "octal digit",
  1178.   "term",
  1179.   "",
  1180.   "factor",
  1181.   "",
  1182.   "",
  1183.   "",
  1184.   "",
  1185.   "",
  1186.   "",
  1187.   "",
  1188.   "",
  1189.   "",
  1190.   "",
  1191.   "",
  1192.   "",
  1193.   "",
  1194.   "",
  1195.   "",
  1196.   "",
  1197.   "",
  1198.   "",
  1199.   "",
  1200.   "",
  1201.   "",
  1202.   "",
  1203.   "",
  1204.   "",
  1205.   "",
  1206.   "",
  1207.   "letter",
  1208.   "",
  1209.   "",
  1210.   "",
  1211.   "simple eol",
  1212.   "identifier",
  1213.   "quoted string",
  1214.   "digit",
  1215.   "",
  1216.   "",
  1217.   "",
  1218.   "",
  1219.   "octal digit",
  1220.   "",
  1221.   "",
  1222.   "",
  1223.   "",
  1224.   "",
  1225.   "",
  1226.   "",
  1227.   "",
  1228.   "",
  1229.   "",
  1230.  
  1231. };
  1232.  
  1233. static char ag_msg[82];
  1234. static char ag_mst[] = "Missing %s";
  1235. static char ag_uet[] = "Unexpected %s";
  1236. static char ag_ac[4] = "' '";
  1237.  
  1238. static void ag_diagnose(void) {
  1239.   int ag_snd = (PCB).sn, ag_k;
  1240.   const char *ag_p;
  1241.   const char *ag_fmt = ag_uet;
  1242.  
  1243.   ag_k = ag_sbt[ag_snd];
  1244.   if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) {
  1245.     ag_p = TOKEN_NAMES[ag_tstt[ag_k]];
  1246.     ag_fmt = ag_mst;
  1247.   }
  1248.   else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) {
  1249.     ag_p = TOKEN_NAMES[(PCB).token_number];
  1250.   }
  1251.   else if (isprint((*(PCB).lab)) && (*(PCB).lab) != '\\') {
  1252.     ag_ac[1] = (*(PCB).lab);
  1253.     ag_p = ag_ac;
  1254.   }
  1255.   else ag_p = "input";
  1256.   sprintf(ag_msg, ag_fmt, ag_p);
  1257.   (PCB).error_message = ag_msg;
  1258.  
  1259.  
  1260. }
  1261. static int ag_action_1_r_proc(void);
  1262. static int ag_action_2_r_proc(void);
  1263. static int ag_action_3_r_proc(void);
  1264. static int ag_action_4_r_proc(void);
  1265. static int ag_action_1_s_proc(void);
  1266. static int ag_action_3_s_proc(void);
  1267. static int ag_action_1_proc(void);
  1268. static int ag_action_2_proc(void);
  1269. static int ag_action_3_proc(void);
  1270. static int ag_action_4_proc(void);
  1271. static int ag_action_5_proc(void);
  1272. static int ag_action_6_proc(void);
  1273. static int ag_action_7_proc(void);
  1274. static int ag_action_8_proc(void);
  1275. static int ag_action_9_proc(void);
  1276. static int ag_action_10_proc(void);
  1277. static int ag_action_11_proc(void);
  1278. static int ag_action_8_proc(void);
  1279.  
  1280.  
  1281. static int (*ag_r_procs_scan[])(void) = {
  1282.   ag_action_1_r_proc,
  1283.   ag_action_2_r_proc,
  1284.   ag_action_3_r_proc,
  1285.   ag_action_4_r_proc
  1286. };
  1287.  
  1288. static int (*ag_s_procs_scan[])(void) = {
  1289.   ag_action_1_s_proc,
  1290.   ag_action_2_r_proc,
  1291.   ag_action_3_s_proc,
  1292.   ag_action_4_r_proc
  1293. };
  1294.  
  1295. static int (*ag_gt_procs_scan[])(void) = {
  1296.   ag_action_1_proc,
  1297.   ag_action_2_proc,
  1298.   ag_action_3_proc,
  1299.   ag_action_4_proc,
  1300.   ag_action_5_proc,
  1301.   ag_action_6_proc,
  1302.   ag_action_7_proc,
  1303.   ag_action_8_proc,
  1304.   ag_action_9_proc,
  1305.   ag_action_10_proc,
  1306.   ag_action_11_proc,
  1307.   ag_action_8_proc
  1308. };
  1309.  
  1310.  
  1311. static int ag_action_10_proc(void) {
  1312.   (PCB).btsx = 0, (PCB).drt = -1;
  1313.   ag_track();
  1314.   return 0;
  1315. }
  1316.  
  1317. static int ag_action_11_proc(void) {
  1318.   (PCB).btsx = 0, (PCB).drt = -1;
  1319.   (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
  1320.   (PCB).ssx--;
  1321.   ag_ra();
  1322.   (PCB).ssx++;
  1323.   ag_track();
  1324.   return 0;
  1325. }
  1326.  
  1327. static int ag_action_3_r_proc(void) {
  1328.   int ag_sd = ag_fl[ag_ap] - 1;
  1329.   if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  1330.   (PCB).btsx = 0, (PCB).drt = -1;
  1331.   (PCB).reduction_token = (parse_token_type) ag_ptt[ag_ap];
  1332.   ag_ra();
  1333.   return 1;
  1334. }
  1335.  
  1336. static int ag_action_3_s_proc(void) {
  1337.   int ag_sd = ag_fl[ag_ap] - 1;
  1338.   if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  1339.   (PCB).btsx = 0, (PCB).drt = -1;
  1340.   (PCB).reduction_token = (parse_token_type) ag_ptt[ag_ap];
  1341.   ag_ra();
  1342.   return 1;
  1343. }
  1344.  
  1345. static int ag_action_4_r_proc(void) {
  1346.   int ag_sd = ag_fl[ag_ap] - 1;
  1347.   if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  1348.   (PCB).reduction_token = (parse_token_type) ag_ptt[ag_ap];
  1349.   return 1;
  1350. }
  1351.  
  1352. static int ag_action_2_proc(void) {
  1353.   (PCB).btsx = 0, (PCB).drt = -1;
  1354.   if ((PCB).ssx >= 38) {
  1355.     (PCB).exit_flag = AG_STACK_ERROR_CODE;
  1356.     PARSER_STACK_OVERFLOW;
  1357.   }
  1358.   (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
  1359.   (PCB).ss[(PCB).ssx] = (PCB).sn;
  1360.   (PCB).ssx++;
  1361.   (PCB).sn = ag_ap;
  1362.   ag_track();
  1363.   return 0;
  1364. }
  1365.  
  1366. static int ag_action_9_proc(void) {
  1367.   if((PCB).drt == -1) {
  1368.     (PCB).drt=(PCB).token_number;
  1369.     (PCB).dssx=(PCB).ssx;
  1370.     (PCB).dsn=(PCB).sn;
  1371.   }
  1372.   ag_prot();
  1373.   (PCB).ss[(PCB).ssx] = (PCB).sn;
  1374.   (PCB).ssx++;
  1375.   (PCB).sn = ag_ap;
  1376.   (PCB).rx = 0;
  1377.   return (PCB).exit_flag == AG_RUNNING_CODE;
  1378. }
  1379.  
  1380. static int ag_action_2_r_proc(void) {
  1381.   (PCB).ssx++;
  1382.   (PCB).sn = ag_ap;
  1383.   return 0;
  1384. }
  1385.  
  1386. static int ag_action_7_proc(void) {
  1387.   --(PCB).ssx;
  1388.   (PCB).exit_flag = AG_SUCCESS_CODE;
  1389.   (PCB).rx = 0;
  1390.   return 0;
  1391. }
  1392.  
  1393. static int ag_action_1_proc(void) {
  1394.   (PCB).exit_flag = AG_SUCCESS_CODE;
  1395.   ag_track();
  1396.   return 0;
  1397. }
  1398.  
  1399. static int ag_action_1_r_proc(void) {
  1400.   (PCB).exit_flag = AG_SUCCESS_CODE;
  1401.   return 0;
  1402. }
  1403.  
  1404. static int ag_action_1_s_proc(void) {
  1405.   (PCB).exit_flag = AG_SUCCESS_CODE;
  1406.   return 0;
  1407. }
  1408.  
  1409. static int ag_action_4_proc(void) {
  1410.   int ag_sd = ag_fl[ag_ap] - 1;
  1411.   (PCB).reduction_token = (parse_token_type) ag_ptt[ag_ap];
  1412.   (PCB).btsx = 0, (PCB).drt = -1;
  1413.   (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
  1414.   if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  1415.   else (PCB).ss[(PCB).ssx] = (PCB).sn;
  1416.   ag_track();
  1417.   while ((PCB).exit_flag == AG_RUNNING_CODE) {
  1418.     unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
  1419.     unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
  1420.     do {
  1421.       unsigned ag_tx = (ag_t1 + ag_t2)/2;
  1422.       if (ag_tstt[ag_tx] < (const unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
  1423.       else ag_t2 = ag_tx;
  1424.     } while (ag_t1 < ag_t2);
  1425.     ag_ap = ag_pstt[ag_t1];
  1426.     if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
  1427.   }
  1428.   return 0;
  1429. }
  1430.  
  1431. static int ag_action_3_proc(void) {
  1432.   int ag_sd = ag_fl[ag_ap] - 1;
  1433.   (PCB).btsx = 0, (PCB).drt = -1;
  1434.   (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
  1435.   if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  1436.   else (PCB).ss[(PCB).ssx] = (PCB).sn;
  1437.   ag_track();
  1438.   (PCB).reduction_token = (parse_token_type) ag_ptt[ag_ap];
  1439.   ag_ra();
  1440.   while ((PCB).exit_flag == AG_RUNNING_CODE) {
  1441.     unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
  1442.     unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
  1443.     do {
  1444.       unsigned ag_tx = (ag_t1 + ag_t2)/2;
  1445.       if (ag_tstt[ag_tx] < (const unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
  1446.       else ag_t2 = ag_tx;
  1447.     } while (ag_t1 < ag_t2);
  1448.     ag_ap = ag_pstt[ag_t1];
  1449.     if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
  1450.   }
  1451.   return 0;
  1452. }
  1453.  
  1454. static int ag_action_8_proc(void) {
  1455.   ag_undo();
  1456.   (PCB).rx = 0;
  1457.   (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
  1458.   ag_diagnose();
  1459.   SYNTAX_ERROR;
  1460.   {(PCB).rx = 1; ag_track();}
  1461.   return (PCB).exit_flag == AG_RUNNING_CODE;
  1462. }
  1463.  
  1464. static int ag_action_5_proc(void) {
  1465.   int ag_sd = ag_fl[ag_ap];
  1466.   if((PCB).drt == -1) {
  1467.     (PCB).drt=(PCB).token_number;
  1468.     (PCB).dssx=(PCB).ssx;
  1469.     (PCB).dsn=(PCB).sn;
  1470.   }
  1471.   if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  1472.   else {
  1473.     ag_prot();
  1474.     (PCB).ss[(PCB).ssx] = (PCB).sn;
  1475.   }
  1476.   (PCB).rx = 0;
  1477.   (PCB).reduction_token = (parse_token_type) ag_ptt[ag_ap];
  1478.   ag_ra();
  1479.   while ((PCB).exit_flag == AG_RUNNING_CODE) {
  1480.     unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
  1481.     unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
  1482.     do {
  1483.       unsigned ag_tx = (ag_t1 + ag_t2)/2;
  1484.       if (ag_tstt[ag_tx] < (const unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
  1485.       else ag_t2 = ag_tx;
  1486.     } while (ag_t1 < ag_t2);
  1487.     ag_ap = ag_pstt[ag_t1];
  1488.     if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
  1489.   }
  1490.   return (PCB).exit_flag == AG_RUNNING_CODE;
  1491. }
  1492.  
  1493. static int ag_action_6_proc(void) {
  1494.   int ag_sd = ag_fl[ag_ap];
  1495.   (PCB).reduction_token = (parse_token_type) ag_ptt[ag_ap];
  1496.   if((PCB).drt == -1) {
  1497.     (PCB).drt=(PCB).token_number;
  1498.     (PCB).dssx=(PCB).ssx;
  1499.     (PCB).dsn=(PCB).sn;
  1500.   }
  1501.   if (ag_sd) {
  1502.     (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
  1503.   }
  1504.   else {
  1505.     ag_prot();
  1506.     (PCB).vs[(PCB).ssx] = ag_null_value;
  1507.     (PCB).ss[(PCB).ssx] = (PCB).sn;
  1508.   }
  1509.   (PCB).rx = 0;
  1510.   while ((PCB).exit_flag == AG_RUNNING_CODE) {
  1511.     unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
  1512.     unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
  1513.     do {
  1514.       unsigned ag_tx = (ag_t1 + ag_t2)/2;
  1515.       if (ag_tstt[ag_tx] < (const unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
  1516.       else ag_t2 = ag_tx;
  1517.     } while (ag_t1 < ag_t2);
  1518.     ag_ap = ag_pstt[ag_t1];
  1519.     if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
  1520.   }
  1521.   return (PCB).exit_flag == AG_RUNNING_CODE;
  1522. }
  1523.  
  1524.  
  1525. void init_parse(void) {
  1526.   unsigned ag_t1 = 0;
  1527.   (PCB).rx = (PCB).fx = 0;
  1528.   (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0;
  1529.   (PCB).exit_flag = AG_RUNNING_CODE;
  1530.   (PCB).key_sp = NULL;
  1531.   (PCB).key_state = 0;
  1532.   (PCB).line = FIRST_LINE;
  1533.    (PCB).column = FIRST_COLUMN;
  1534.   (PCB).btsx = 0, (PCB).drt = -1;
  1535.   while (ag_tstt[ag_t1] == 0) {
  1536.     ag_ap = ag_pstt[ag_t1];
  1537.     (ag_gt_procs_scan[ag_astt[ag_t1]])();
  1538.     ag_t1 = ag_sbt[(PCB).sn];
  1539.   }
  1540. }
  1541.  
  1542. void parse(void) {
  1543.   (PCB).lab[(PCB).fx++] = (PCB).input_code;
  1544.   while ((PCB).exit_flag == AG_RUNNING_CODE) {
  1545.     while (1) {
  1546.       unsigned char *ag_p;
  1547.       int ag_ch;
  1548.       if ((PCB).rx >= (PCB).fx) return;
  1549.       ag_ch = CONVERT_CASE((PCB).lab[(PCB).rx++]);
  1550.       if ((PCB).key_sp) {
  1551.         if (ag_ch != *(PCB).key_sp++) {
  1552.           (PCB).rx = (PCB).save_index;
  1553.           (PCB).key_sp = NULL;
  1554.           (PCB).key_state = 0;
  1555.           break;
  1556.         } else if (*(PCB).key_sp) continue;
  1557.         if (ag_key_act[(PCB).key_state] == ag_cf_end_key) {
  1558.           int ag_k1;
  1559.           int ag_k2;
  1560.           if ((PCB).rx >= (PCB).fx) {
  1561.             (PCB).rx--;
  1562.             (PCB).key_sp--;
  1563.             return;
  1564.           }
  1565.           (PCB).key_sp = NULL;
  1566.           ag_k1 = ag_key_parm[(PCB).key_state];
  1567.           ag_k2 = ag_key_pt[ag_k1];
  1568.           if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])])
  1569.             (PCB).rx = (PCB).save_index;
  1570.           else {
  1571.             (PCB).token_number =  (parse_token_type) ag_key_pt[ag_k1+1];
  1572.             (PCB).key_state = 0;
  1573.           }
  1574.           break;
  1575.         }
  1576.         else {
  1577.           (PCB).token_number = (parse_token_type) ag_key_parm[(PCB).key_state];
  1578.           (PCB).key_state = 0;
  1579.           (PCB).key_sp = NULL;
  1580.         }
  1581.         break;
  1582.       }
  1583.       if ((PCB).key_state == 0) {
  1584.         (PCB).token_number = (parse_token_type) AG_TCV(ag_ch);
  1585.         if (((PCB).key_state = ag_key_index[(PCB).sn]) == 0) break;
  1586.         (PCB).save_index = 1;
  1587.       }
  1588.       ag_p = &ag_key_ch[(PCB).key_state];
  1589.       while (*ag_p < ag_ch) ag_p++;
  1590.       if (*ag_p == ag_ch) {
  1591.         (PCB).key_state = (int)(ag_p - ag_key_ch);
  1592.         switch (ag_key_act[(PCB).key_state]) {
  1593.         case ag_cf_set_key: {
  1594.           int ag_k1;
  1595.           int ag_k2;
  1596.           if ((PCB).rx >= (PCB).fx) {
  1597.             (PCB).rx--;
  1598.             return;
  1599.           }
  1600.           ag_k1 = ag_key_parm[(PCB).key_state];
  1601.           ag_k2 = ag_key_pt[ag_k1];
  1602.           (PCB).key_state = ag_key_jmp[(PCB).key_state];
  1603.           if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])]) break;
  1604.           (PCB).save_index = (PCB).rx;
  1605.           (PCB).token_number = (parse_token_type) ag_key_pt[ag_k1+1];
  1606.           break;
  1607.         }
  1608.         case ag_set_key:
  1609.           (PCB).save_index = (PCB).rx;
  1610.           (PCB).token_number = (parse_token_type) ag_key_parm[(PCB).key_state];
  1611.         case ag_jmp_key:
  1612.           (PCB).key_state = ag_key_jmp[(PCB).key_state];
  1613.           continue;
  1614.         case ag_cf_end_key:
  1615.         case ag_end_key:
  1616.           (PCB).key_sp = ag_key_ends + ag_key_jmp[(PCB).key_state];
  1617.           continue;
  1618.         case ag_accept_key:
  1619.           (PCB).token_number = (parse_token_type) ag_key_parm[(PCB).key_state];
  1620.           (PCB).key_state = 0;
  1621.           break;
  1622.         case ag_cf_accept_key: {
  1623.           int ag_k1;
  1624.           int ag_k2;
  1625.           if ((PCB).rx >= (PCB).fx) {
  1626.             (PCB).rx--;
  1627.             return;
  1628.           }
  1629.           ag_k1 = ag_key_parm[(PCB).key_state];
  1630.           ag_k2 = ag_key_pt[ag_k1];
  1631.           if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])])
  1632.             (PCB).rx = (PCB).save_index;
  1633.           else {
  1634.             (PCB).rx--;
  1635.             (PCB).token_number = (parse_token_type) ag_key_pt[ag_k1+1];
  1636.             (PCB).key_state = 0;
  1637.           }
  1638.           break;
  1639.         }
  1640.         }
  1641.         break;
  1642.       } else {
  1643.         (PCB).rx = (PCB).save_index;
  1644.         (PCB).key_state = 0;
  1645.         break;
  1646.       }
  1647.     }
  1648.  
  1649.     {
  1650.       unsigned ag_t1 = ag_sbt[(PCB).sn];
  1651.       unsigned ag_t2 = ag_sbe[(PCB).sn] - 1;
  1652.       do {
  1653.         unsigned ag_tx = (ag_t1 + ag_t2)/2;
  1654.         if (ag_tstt[ag_tx] > (const unsigned char)(PCB).token_number)
  1655.           ag_t1 = ag_tx + 1;
  1656.         else ag_t2 = ag_tx;
  1657.       } while (ag_t1 < ag_t2);
  1658.       if (ag_tstt[ag_t1] != (PCB).token_number)  ag_t1 = ag_sbe[(PCB).sn];
  1659.       ag_ap = ag_pstt[ag_t1];
  1660.       (ag_gt_procs_scan[ag_astt[ag_t1]])();
  1661.     }
  1662.   }
  1663.  
  1664. }
  1665.  
  1666.  
  1667.